<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 向字符串添加空格 -->
    <script>
      var addSpaces = function (s, spaces) {
        let s1 = ''
        let m = 0
        for (let i = 0; i < spaces.length; i++) {
          s1 += s.slice(m, spaces[i])
          s1 += ' '
          m = spaces[i]
        }
        s1 += s.slice(m, s.length)
        return s1
      }
      console.log(addSpaces('EnjoyYourCoffee', [5, 9]))
    </script>
  </body>
</html>
